import os
import shutil

filePath = 'D:/课题/data/result/decompress1/txt'
target = os.walk(filePath)
# print(target)

for dirpath, dirnames, filenames in target:
    for filename in filenames:
        print(dirpath + "/" + filename)
        targetDir = "D:/课题/data/result/decompress1/txt1" + "/" + dirpath.split("\\")[1]
        if not os.path.exists(targetDir):
            os.makedirs(targetDir)  # 创建路径
        shutil.copyfile(dirpath + "/" + filename,
                        targetDir + "/" + filename)
